<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: new_attributes.php 70 2013-09-21 12:00:23Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 70 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 12:00:23 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

require('includes/application_top.php');
require(DIR_WS_MODULES.'new_attributes_config.php');
require(DIR_FS_INC.'inc.findTitle.php');
require_once(DIR_FS_INC.'inc.format_filesize.php');

if(isset($cPathID) && $_POST['action'] == 'change') {
	include(DIR_WS_MODULES.'new_attributes_change.php');
	redirect( './'.FILENAME_CATEGORIES.'?cPath='.$cPathID.'&pID='.$_POST['current_product_id'] );
}

require(DIR_WS_INCLUDES.'metatag.php');
?>

</head>
<body>
<?php
  require(DIR_WS_INCLUDES.'header.php');
?>
<div id="wrapper">
	<table class="outerTable" cellpadding="0" cellspacing="0">
	  <tr>
	    <td class="columnLeft2" width="<?php echo BOX_WIDTH; ?>" valign="top">
			<?php require(DIR_WS_INCLUDES.'column_left.php'); ?>
		</td>
	    <td class="boxCenter" valign="top">
	    	<table border="0" width="100%" cellspacing="0" cellpadding="2">
				<?php
				  switch($_POST['action']) {
				    case 'edit':
				      if ($_POST['copy_product_id'] != 0) {
				          $attrib = $db->db_query("SELECT
														products_id,
														options_id,
														options_values_id,
														options_values_price,
														price_prefix,
														attributes_model,
														attributes_stock,
														options_values_weight,
														weight_prefix
													FROM
														".TABLE_PRODUCTS_ATTRIBUTES."
													WHERE
														products_id = ".$_POST['copy_product_id']);

				          while (!$attrib->EOF) {
				              $db->db_query("INSERT INTO
				              					".TABLE_PRODUCTS_ATTRIBUTES."
				              						(products_id,
				              						options_id,
				              						options_values_id,
				              						options_values_price,
				              						price_prefix,
				              						attributes_model,
				              						attributes_stock,
				              						options_values_weight,
				              						weight_prefix)
				              				VALUES
				              						('".$_POST['current_product_id']."',
				              						'".$attrib->fields['options_id']."',
				              						'".$attrib->fields['options_values_id']."',
				              						'".$attrib->fields['options_values_price']."',
				              						'".$attrib->fields['price_prefix']."',
				              						'".$attrib->fields['attributes_model']."',
				              						'".$attrib->fields['attributes_stock']."',
				              						'".$attrib->fields['options_values_weight']."',
				              						'".$attrib->fields['weight_prefix']."')");
				              $attrib->MoveNext();
				          }
				      }
				      $pageTitle = TITLE_EDIT.': '.findTitle($_POST['current_product_id']);
				      include(DIR_WS_MODULES.'new_attributes_include.php');
				      break;

				    case 'change':
				      $pageTitle = TITLE_UPDATED;
				      include(DIR_WS_MODULES.'new_attributes_change.php');
				      include(DIR_WS_MODULES.'new_attributes_select.php');
				      break;

				    default:
				      $pageTitle = TITLE_EDIT;
				      include(DIR_WS_MODULES.'new_attributes_select.php');
				      break;
				  }
				?>
	    	</table>
	    </td>
	  </tr>
	</table>
</div>
<?php require(DIR_WS_INCLUDES.'footer.php'); ?>
</body>
</html>
<?php require(DIR_WS_INCLUDES.'application_bottom.php'); ?>